package com.ghost.manager
{
	import com.ghost.model.Global_data;
	import com.ghost.model.Object_pool;
	import com.ghost.utils.MovieClipUtil;
	
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.ui.Mouse;

	/**
	 * 鼠标管理 
	 * @author ghost
	 */	
	public class Mouse_manager
	{
		private static var instance:Mouse_manager;
		public static function getInstance():Mouse_manager
		{
			if(!instance)instance = new Mouse_manager();
			return instance;
		}
		public function Mouse_manager()
		{
			
		}
		public var mouse_main:Sprite;
		/**
		 * @param str 鼠标状态字段
		 */		
		public function change_status(str:String="common"):void
		{
			if(str=="common")
			{
				Global_data.Game_s.removeEventListener(Event.ENTER_FRAME,Enter_Handler);
				Mouse.show();
				MovieClipUtil.removeAllChild(mouse_main);
			}
			else
			{
				if(Global_data.Game_s)Global_data.Game_s.addEventListener(MouseEvent.MOUSE_MOVE,Enter_Handler);
				Mouse.hide();
				if(Object_pool.mouse_status_pool.containsKey(str))mouse_main.addChild(Object_pool.mouse_status_pool.get(str));
			}
		}
		private function Enter_Handler(e:MouseEvent):void
		{
			if(Global_data.Game_s)
			{
				mouse_main.x = Global_data.Game_s.mouseX-mouse_main.width/2;
				mouse_main.y = Global_data.Game_s.mouseY-mouse_main.height/2;
				e.updateAfterEvent();
			}
		}
	}
}